<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home></home>
  </div>

  <template id="tpl">
    <div>
      <h2>我是home页</h2>
      <common-head :a="2" b="你好" c="AAA"></common-head>
    </div>
  </template>

  <script src="./vue.js"></script>
  <script>
    const CommonHead = {
      template:`
        <div>
          公共的头部组件
          {{a}}
          {{b}}
          {{c}}
          {{d}}
          <button v-for="item in e" :key="item">{{item}}</button>
        </div>
      `,
      // properties  怎么接收
      props: {
        // 只验证类型
        a:Number,
        // 只验证类型  类型 是数组中的一个即可
        b:[String,Number],
        c:{
          type: String,
          required: true
        },
        d: {
          type:String,
          default: '我是默认值'
        },
        e:{
          type:Array,
          default: ()=> [1,2,3]
        }
      }
    }

    const Home = {
      template:"#tpl",
      components:{
        CommonHead
      },
      data(){
        return {
          homeTitle:'我是home的标题，我是data中定义的'
        }
      }
    }
    Vue.component('Home', Home)
  
    const vm = new Vue({
      el:'#app'
    })
  </script>
</body>
</html>